# 参数
# 目的：业务的代码有的地方写得有点'死'，我们想把他写'活'
# 知识：定参
def total(start,end):
    result = 0
    for i in range(start,end):
        result = result + i
    print(f'他们的和为：{result}')

#调用时，对应的传入参数即可
total(5,51)
total(start=5,end=51)
total(end=51,start=5)

# 默认值：传了就改变了默认值。不传就表示使用默认值
# 注意：默认值放必填参的后面
def total2(start,end,step=1):
    result = 0
    for i in range(start,end,step):
        result = result + i
    print(f'他们的和为：{result}')

total2(5,51)
total2(5,51,5)

# 变参（*，**） --- 选学
# *:当元组传
# **:当字典传
def total3(*args):
    result = 0
    for i in range(args[0],args[1]):
        result = result + i
    print(f'他们的和为：{result}')

total2(5,51)


def total4(start,end,*args):
    result = 0
    for i in range(start,end):
        result = result + i
    print(f'他们的和为：{result}')

total4(5, 51)
total4(5, 51,3,4,5,32,123)

def total5(**kwargs):
    result = 0
    for i in range(kwargs['start'],kwargs['end']):
        result = result + i
    print(f'他们的和为：{result}')

total5(start=5,end=51)
total5(start=5,end=51,name='caichang')